package cj.web.kly.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.kly.domain.SourceInfor;
import cj.web.kly.domain.Subject;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SourceInforDAO{
	
	@SQL("SELECT * FROM SourceInfor WHERE deleteFlag=1 ORDER BY updateAt desc ")
    List<SourceInfor> queryAll();
	
	@SQL("SELECT * FROM SourceInfor WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ORDER BY updateAt desc LIMIT :t.start,:t.length ")
    List<SourceInfor> query(@SQLParam("t") SourceInfor obj);
		
	@SQL("SELECT count(1) FROM SourceInfor WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' }" )
    int querySize(@SQLParam("t") SourceInfor obj);
    
    @SQL("SELECT * FROM SourceInfor WHERE id=:1")
    SourceInfor queryById(int id);
    
    @SQL("INSERT INTO SourceInfor ("
			        		+ "name,"
			        		+ "descs,"
			        		+ "deleteFlag,"
			        		+ "createUser,"
			        		+ "createAt,"
			        		+ "updateUser,"
			        		+ "updateAt"
							+") VALUES ("
							+ ":t.name,"
							+ ":t.descs,"
							+ "1,"
							+ ":t.createUser,"
							+ "now(),"
							+ ":t.updateUser,"
							+ "now()) ")
    void create(@SQLParam("t") SourceInfor obj);
	
	@SQL("UPDATE SourceInfor SET name=:t.name,descs=:t.descs,updateUser=:t.updateUser,updateAt=now() WHERE id=:t.id")
    void update(@SQLParam("t") SourceInfor obj);
    
    @SQL("UPDATE SourceInfor SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}